

package flc.ast.adapter;


import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ConvertUtils;
import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.List;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class AlbumAdapter extends StkProviderMultiAdapter<String> {

    public AlbumAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new StringProvider());
    }

    private class StringProvider extends BaseItemProvider<String> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_album;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, String bean) {
            baseViewHolder.setText(R.id.tvAlbumItemName, FileUtils.getFileName(bean));
            List<File> files = FileUtils.listFilesInDir(bean);
            if (files.size() != 0) {
                Glide.with(baseViewHolder.itemView).load(files.get(0).getPath()).into((ImageView) baseViewHolder.getView(R.id.ivAlbumItemImg));
            }
            baseViewHolder.setText(R.id.tvAlbumItemSize, getContext().getString(R.string.album_size_num, files.size()));
        }
    }

}
